<template>
    <el-table
        v-if="isCheck"
        :data="dataList"
        style="width: 100%"
        :border="true"
    >
        <el-table-column fixed prop="date" label="术语编号" align="center"/>
        <el-table-column prop="name" label="中文名称" align="center"/>
        <el-table-column prop="address" label="英文名称" align="center"/>
        <el-table-column prop="address" label="术语条文" align="center"/>
        <el-table-column prop="address" label="术语解释" align="center"/>
        <el-table-column prop="address" label="术语标签" align="center"/>
        <template #empty>
            <span>暂无数据</span>
        </template>
    </el-table>
    <el-table
        v-else
        :data="dataList"
        style="width: 100%"
        :border="true"
    >
        <el-table-column prop="articleNumber" label="条文编号" align="center"/>
        <el-table-column prop="articleContent" label="条文" align="center"/>
        <el-table-column prop="articleRemark" label="条文说明" align="center"/>
        <el-table-column prop="twbqZy" label="条文标签（专业）" align="center">
            <template #default="scope">
              {{ dictList.filter(item => item.code == scope.row.twbqZy)[0].name }}
            </template>
        </el-table-column>
        <el-table-column prop="twbqGl" label="条文标签（管理）" align="center">
          <template #default="scope">
              {{ dictList.filter(item => item.code == scope.row.twbqGl)[0].name }}
            </template>
        </el-table-column>
        <template #empty>
            <span>暂无数据</span>
        </template>
    </el-table>
</template>
<script setup lang="ts">
import axios from "axios";
import { onMounted, ref, watch } from 'vue';
  import { getServerUrl } from "@/utils/url";
  const serverUrl = getServerUrl();
interface List{
  code: string,
  name: string
}
    const props = defineProps({
      tab: {
        type: String,
        default: ''
      },
      systemId: {
        type: String,
        default: ''
      },
      currentTab: {
          type: String,
          default: ''
      },
      isCheck: {
          type: Boolean,
          default: true
      }
  })
const dataList = ref([])
const dictList = ref<List[]>([])

watch(() => props.currentTab, (newVal) => {
    if (newVal === 'tab5' && props.tab === 'tab5') {
        getMainCompileUnit()
    }
})

const getMainCompileUnit = () => {
  dataList.value = []
  axios.get(
        serverUrl + "standardSystem/article/list?systemId=" + props.systemId + "&unitType=0&pageNum=1&pageSize=100",
      ).then(res => {
          dataList.value = res.data.data.list
      })
}

onMounted(() => {
  axios.get(
        serverUrl + "api/standardDictionary/getDictList/T017",
      ).then(res => {
          dictList.value = res.data.data
      })
})
    // const emit = defineEmits(['querylist', 'detaillist'])
</script>
<style lang="scss" scoped></style>